﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestComp : MonoBehaviour
{
    //公开变量Unity默认会自动序化
    public Vector3 postion;

    [SerializeField] //非公开变量需要加上 [SerializeField]特性才会被序列化
    private string des;

    //想要公开的变量不序列化可以加上  [HideInInspector]
    [HideInInspector]
    public int age;

    //浮点数变量可以使用   [Range(0, 1)] 让其在检查面板中显示滑条,并限制范围
    [Range(0, 1)]
    public float height;

    public Color color;
    public string[] stringArray;
    public Color[] colorArray;
    public Dog dog;

    public void Fun()
    {
        Debug.Log("Fun被调用");
    }
}
//我们自己写的类,需要加上[System.Serializable]才会被Unity序列化
[System.Serializable]
public class Dog
{
    public string name;
    public int age;
}